---
layout: "default"
title: "Operator: +="
description: "Swift documentation for the '+=' operator."
root: "/v3.0"
---

<code class="language-swift"> operator += {
    associativity right
    precedence 
    assignment
}</code>

<h3>Declarations</h3>

<div class="declaration" id="func-plseq_-inout-double-rhs_-double">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-double-rhs_-double">func +=(<wbr>_:<wbr> inout Double, rhs: Double)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-double-rhs_-double"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Double, rhs: Double)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-float-rhs_-float">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-float-rhs_-float">func +=(<wbr>_:<wbr> inout Float, rhs: Float)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-float-rhs_-float"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Float, rhs: Float)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-float80-rhs_-float80">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-float80-rhs_-float80">func +=(<wbr>_:<wbr> inout Float80, rhs: Float80)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-float80-rhs_-float80"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Float80, rhs: Float80)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-int-rhs_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-int-rhs_-int">func +=(<wbr>_:<wbr> inout Int, rhs: Int)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-int-rhs_-int"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Int, rhs: Int)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-int8-rhs_-int8">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-int8-rhs_-int8">func +=(<wbr>_:<wbr> inout Int8, rhs: Int8)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-int8-rhs_-int8"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Int8, rhs: Int8)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-int16-rhs_-int16">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-int16-rhs_-int16">func +=(<wbr>_:<wbr> inout Int16, rhs: Int16)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-int16-rhs_-int16"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Int16, rhs: Int16)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-int32-rhs_-int32">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-int32-rhs_-int32">func +=(<wbr>_:<wbr> inout Int32, rhs: Int32)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-int32-rhs_-int32"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Int32, rhs: Int32)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-int64-rhs_-int64">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-int64-rhs_-int64">func +=(<wbr>_:<wbr> inout Int64, rhs: Int64)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-int64-rhs_-int64"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout Int64, rhs: Int64)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-uint-rhs_-uint">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-uint-rhs_-uint">func +=(<wbr>_:<wbr> inout UInt, rhs: UInt)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-uint-rhs_-uint"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout UInt, rhs: UInt)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-uint8-rhs_-uint8">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-uint8-rhs_-uint8">func +=(<wbr>_:<wbr> inout UInt8, rhs: UInt8)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-uint8-rhs_-uint8"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout UInt8, rhs: UInt8)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-uint16-rhs_-uint16">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-uint16-rhs_-uint16">func +=(<wbr>_:<wbr> inout UInt16, rhs: UInt16)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-uint16-rhs_-uint16"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout UInt16, rhs: UInt16)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-uint32-rhs_-uint32">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-uint32-rhs_-uint32">func +=(<wbr>_:<wbr> inout UInt32, rhs: UInt32)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-uint32-rhs_-uint32"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout UInt32, rhs: UInt32)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq_-inout-uint64-rhs_-uint64">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq_-inout-uint64-rhs_-uint64">func +=(<wbr>_:<wbr> inout UInt64, rhs: UInt64)</a>
        
<div class="comment collapse" id="comment-func-plseq_-inout-uint64-rhs_-uint64"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=(lhs: inout UInt64, rhs: UInt64)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-c_-collection_-inout-c-iterator-element-rhs_-c">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-c_-collection_-inout-c-iterator-element-rhs_-c">func <wbr>+= &lt;C : Collection&gt;(<wbr>_:<wbr> inout [C.Iterator.Element], rhs: C)</a>
        
<div class="comment collapse" id="comment-func-plseq-c_-collection_-inout-c-iterator-element-rhs_-c"><div class="p">
    <p>Appends the elements of a collection to an array.</p>

<p>Use this operator to append the elements of a collection to the end of
an array with same <code>Element</code> type. This example appends
the elements of a <code>Range&lt;Int&gt;</code> instance to an array of integers.</p>

<pre><code class="language-swift">var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints &quot;[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> The array to append to.
  <strong>rhs:</strong> A collection.</p>

<p><strong>Complexity:</strong> O(<em>n</em>), where <em>n</em> is the length of the resulting array.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;C : Collection&gt;(lhs: inout [C.Iterator.Element], rhs: C)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-c_-collection_-inout-arrayslice-c-iterator-element-rhs_-c">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-c_-collection_-inout-arrayslice-c-iterator-element-rhs_-c">func <wbr>+= &lt;C : Collection&gt;(<wbr>_:<wbr> inout ArraySlice&lt;C.Iterator.Element&gt;, rhs: C)</a>
        
<div class="comment collapse" id="comment-func-plseq-c_-collection_-inout-arrayslice-c-iterator-element-rhs_-c"><div class="p">
    <p>Appends the elements of a collection to an <code>ArraySlice</code> instance.</p>

<p>Use this operator to append the elements of a collection to the end of
an <code>ArraySlice</code> instance with same <code>Element</code> type. This example appends
the elements of a <code>Range&lt;Int&gt;</code> instance to an array of integers.</p>

<pre><code class="language-swift">var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints &quot;[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> The array to append to.
  <strong>rhs:</strong> A collection.</p>

<p><strong>Complexity:</strong> O(<em>n</em>), where <em>n</em> is the length of the resulting array.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;C : Collection&gt;(lhs: inout ArraySlice&lt;C.Iterator.Element&gt;, rhs: C)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-c_-collection_-inout-contiguousarray-c-iterator-element-rhs_-c">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-c_-collection_-inout-contiguousarray-c-iterator-element-rhs_-c">func <wbr>+= &lt;C : Collection&gt;(<wbr>_:<wbr> inout ContiguousArray&lt;C.Iterator.Element&gt;, rhs: C)</a>
        
<div class="comment collapse" id="comment-func-plseq-c_-collection_-inout-contiguousarray-c-iterator-element-rhs_-c"><div class="p">
    <p>Appends the elements of a collection to a <code>ContiguousArray</code> instance.</p>

<p>Use this operator to append the elements of a collection to the end of
a <code>ContiguousArray</code> instance with same <code>Element</code> type. This example appends
the elements of a <code>Range&lt;Int&gt;</code> instance to an array of integers.</p>

<pre><code class="language-swift">var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints &quot;[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> The array to append to.
  <strong>rhs:</strong> A collection.</p>

<p><strong>Complexity:</strong> O(<em>n</em>), where <em>n</em> is the length of the resulting array.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;C : Collection&gt;(lhs: inout ContiguousArray&lt;C.Iterator.Element&gt;, rhs: C)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-element-c_-collection-where-c-iterator-element-element_-inout-contiguousarraybuffer-element-rhs_-c">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-element-c_-collection-where-c-iterator-element-element_-inout-contiguousarraybuffer-element-rhs_-c">func <wbr>+= &lt;Element, C : Collection where C.Iterator.Element == Element&gt;(<wbr>_:<wbr> inout _ContiguousArrayBuffer&lt;Element&gt;, rhs: C)</a>
        
<div class="comment collapse" id="comment-func-plseq-element-c_-collection-where-c-iterator-element-element_-inout-contiguousarraybuffer-element-rhs_-c"><div class="p">
    <p>Append the elements of <code>rhs</code> to <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;Element, C : Collection where C.Iterator.Element == Element&gt;(lhs: inout _ContiguousArrayBuffer&lt;Element&gt;, rhs: C)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-pointee_-inout-unsafemutablepointer-pointee-rhs_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-pointee_-inout-unsafemutablepointer-pointee-rhs_-int">func += &lt;Pointee&gt;(<wbr>_:<wbr> inout UnsafeMutablePointer&lt;Pointee&gt;, rhs: Int)</a>
        
<div class="comment collapse" id="comment-func-plseq-pointee_-inout-unsafemutablepointer-pointee-rhs_-int"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;Pointee&gt;(lhs: inout UnsafeMutablePointer&lt;Pointee&gt;, rhs: Int)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-pointee_-inout-unsafepointer-pointee-rhs_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-pointee_-inout-unsafepointer-pointee-rhs_-int">func += &lt;Pointee&gt;(<wbr>_:<wbr> inout UnsafePointer&lt;Pointee&gt;, rhs: Int)</a>
        
<div class="comment collapse" id="comment-func-plseq-pointee_-inout-unsafepointer-pointee-rhs_-int"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;Pointee&gt;(lhs: inout UnsafePointer&lt;Pointee&gt;, rhs: Int)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-s_-sequence_-inout-s-iterator-element-rhs_-s">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-s_-sequence_-inout-s-iterator-element-rhs_-s">func <wbr>+= &lt;S : Sequence&gt;(<wbr>_:<wbr> inout [S.Iterator.Element], rhs: S)</a>
        
<div class="comment collapse" id="comment-func-plseq-s_-sequence_-inout-s-iterator-element-rhs_-s"><div class="p">
    <p>Appends the elements of a sequence to an array.</p>

<p>Use this operator to append the elements of a sequence to the end of
an array with same <code>Element</code> type. This example appends
the elements of a <code>Range&lt;Int&gt;</code> instance to an array of integers.</p>

<pre><code class="language-swift">var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints &quot;[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> The array to append to.
  <strong>rhs:</strong> A collection or finite sequence.</p>

<p><strong>Complexity:</strong> O(<em>n</em>), where <em>n</em> is the length of the resulting array.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;S : Sequence&gt;(lhs: inout [S.Iterator.Element], rhs: S)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-s_-sequence_-inout-arrayslice-s-iterator-element-rhs_-s">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-s_-sequence_-inout-arrayslice-s-iterator-element-rhs_-s">func <wbr>+= &lt;S : Sequence&gt;(<wbr>_:<wbr> inout ArraySlice&lt;S.Iterator.Element&gt;, rhs: S)</a>
        
<div class="comment collapse" id="comment-func-plseq-s_-sequence_-inout-arrayslice-s-iterator-element-rhs_-s"><div class="p">
    <p>Appends the elements of a sequence to an <code>ArraySlice</code> instance.</p>

<p>Use this operator to append the elements of a sequence to the end of
an <code>ArraySlice</code> instance with same <code>Element</code> type. This example appends
the elements of a <code>Range&lt;Int&gt;</code> instance to an array of integers.</p>

<pre><code class="language-swift">var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints &quot;[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> The array to append to.
  <strong>rhs:</strong> A collection or finite sequence.</p>

<p><strong>Complexity:</strong> O(<em>n</em>), where <em>n</em> is the length of the resulting array.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;S : Sequence&gt;(lhs: inout ArraySlice&lt;S.Iterator.Element&gt;, rhs: S)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-s_-sequence_-inout-contiguousarray-s-iterator-element-rhs_-s">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-s_-sequence_-inout-contiguousarray-s-iterator-element-rhs_-s">func <wbr>+= &lt;S : Sequence&gt;(<wbr>_:<wbr> inout ContiguousArray&lt;S.Iterator.Element&gt;, rhs: S)</a>
        
<div class="comment collapse" id="comment-func-plseq-s_-sequence_-inout-contiguousarray-s-iterator-element-rhs_-s"><div class="p">
    <p>Appends the elements of a sequence to a <code>ContiguousArray</code> instance.</p>

<p>Use this operator to append the elements of a sequence to the end of
a <code>ContiguousArray</code> instance with same <code>Element</code> type. This example appends
the elements of a <code>Range&lt;Int&gt;</code> instance to an array of integers.</p>

<pre><code class="language-swift">var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints &quot;[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> The array to append to.
  <strong>rhs:</strong> A collection or finite sequence.</p>

<p><strong>Complexity:</strong> O(<em>n</em>), where <em>n</em> is the length of the resulting array.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;S : Sequence&gt;(lhs: inout ContiguousArray&lt;S.Iterator.Element&gt;, rhs: S)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-t_-integerarithmetic_-inout-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-t_-integerarithmetic_-inout-t-rhs_-t">func <wbr>+= &lt;T : _IntegerArithmetic&gt;(<wbr>_:<wbr> inout T, rhs: T)</a>
        
<div class="comment collapse" id="comment-func-plseq-t_-integerarithmetic_-inout-t-rhs_-t"><div class="p">
    <p>Adds <code>lhs</code> and <code>rhs</code> and stores the result in <code>lhs</code>, trapping in
case of arithmetic overflow (except in -Ounchecked builds).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;T : _IntegerArithmetic&gt;(lhs: inout T, rhs: T)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-t_-floatingpoint_-inout-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-t_-floatingpoint_-inout-t-rhs_-t">func <wbr>+= &lt;T : FloatingPoint&gt;(<wbr>_:<wbr> inout T, rhs: T)</a>
        
<div class="comment collapse" id="comment-func-plseq-t_-floatingpoint_-inout-t-rhs_-t"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;T : FloatingPoint&gt;(lhs: inout T, rhs: T)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-t_-strideable_-inout-t-rhs_-t-stride">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-t_-strideable_-inout-t-rhs_-t-stride">func <wbr>+= &lt;T : Strideable&gt;(<wbr>_:<wbr> inout T, rhs: T.Stride)</a>
        
<div class="comment collapse" id="comment-func-plseq-t_-strideable_-inout-t-rhs_-t-stride"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;T : Strideable&gt;(lhs: inout T, rhs: T.Stride)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-plseq-t_-unsignedinteger_-inout-t-rhs_-t-disallowmixedsignarithmetic">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-plseq-t_-unsignedinteger_-inout-t-rhs_-t-disallowmixedsignarithmetic">func <wbr>+= &lt;T : UnsignedInteger&gt;(<wbr>_:<wbr> inout T, rhs: T._DisallowMixedSignArithmetic)</a>
        
<div class="comment collapse" id="comment-func-plseq-t_-unsignedinteger_-inout-t-rhs_-t-disallowmixedsignarithmetic"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func +=&lt;T : UnsignedInteger&gt;(lhs: inout T, rhs: T._DisallowMixedSignArithmetic)</code>
    
    
</div></div>
</div>
